<template>
  <div class="dashboard-container">
    <component :is="currentRole" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'
import checkPermission from '@/utils/permission'
export default {
  name: 'Dashboard',
  components: { adminDashboard, editorDashboard },
  data() {
    return {
      currentRole: 'adminDashboard'
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    const list = ['dfZongjian','dfAdmin','dfEditor','dfChejian','admin']
    // console.log(this.$store.state.user.userInfo[0].roleList[0].roleName)
    if (this.$store.state.user.userInfo[0].roleList[0].roleName !== 'superAdmin'){
      if (!checkPermission(list)) {
        this.currentRole = 'editorDashboard'
      }
    }
    
  }
}
</script>
